import 'package:baselib/base/base_view_model.dart';
import 'package:baselib/net/baseentity.dart';
import 'package:framelib/route/navigator.dart';
import 'package:framelib/route/route_config.dart';
import 'package:get/get.dart';
import 'package:moduletwo/module/service/get_one_service.dart';
import '../../entity/user_entity.dart';
import 'package:flustars/flustars.dart';

class GetOneViewModel extends BaseViewModel<GetOneService>{
  GetOneService getOneService;


  @override
  GetOneService createService()=>(getOneService=GetOneService());

  RxInt count=0.obs;

  increase(){
      // count++;
    // count.value=getOneService.getCount(count.value);
    // var countTwo = getOneService.getCountTwo(1);
    // print('countTwo-->$countTwo');
    _getData();
      // update();
  }

    @override
  void onReady() {
    // TODO: implement onReady
    _getData();
    super.onReady();
  }

  void _getData() async{
        print('getData-->');
        // increase();
        BaseEntity post =await getOneService.getData();
        count.value=(post.data as UserEntity)?.age;
        LogUtil.e("返回的数据 data=${post?.toString()}");
        // DioUtils.instance.post('https://img.baidu.com/it/u=2605112544,759365927&fm=15&fmt=auto&gp=0.jpg');
    
    var sum=[10,15,29,66,88];
    var sumCur=sum.fold(0, (pre, cur) => pre+cur);
    LogUtil.e("当前求和 值=${sumCur}");
  }

  toNextPage() async{
    NavigatorUtils.pushByName(RouteConfig.getTwoMainTabPage,arguments: {'name':'小李','userEntity':UserEntity(name: '小丽')},resultFunc: (value){
      print('_toNextPage-->value=${value}');
    });
    // var post =await getOneService.getDataTwo();
    //
    // LogUtil.e("返回的数据 data=${post?.toString()}");
   }



}